package com.supostacks.application.application.impl;

import com.alibaba.fastjson.JSONObject;
import com.supostacks.application.application.IFileManagementApplication;
import com.supostacks.domain.service.IFileManagementService;
import com.supostacks.domain.vo.BaseVo;
import com.supostacks.domain.vo.FileManagementVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class FileManagementApplicationImpl implements IFileManagementApplication {

    @Resource
    IFileManagementService fileManagementService;

    @Override
    public String insert(JSONObject data) {
        FileManagementVo fileManagementVo = JSONObject.toJavaObject(data, FileManagementVo.class);
        return fileManagementService.insert(fileManagementVo);
    }

    @Override
    public void deleteById(String id) {
        fileManagementService.deleteById(id);
    }

    @Override
    public String updateById(JSONObject data) {
        FileManagementVo fileManagementVo = JSONObject.toJavaObject(data, FileManagementVo.class);
        return fileManagementService.updateById(fileManagementVo);
    }

    @Override
    public BaseVo selectById(String id) {
        return fileManagementService.selectById(id);
    }

    @Override
    public List<BaseVo> selectList(JSONObject param) {
        List<FileManagementVo> vos = fileManagementService.selectList(param);
        return new ArrayList<>(vos);
    }

    @Override
    public JSONObject selectByPage(JSONObject options, int pageNo, int pageSize) {
        return fileManagementService.selectByPage(options, pageNo, pageSize);
    }

    @Override
    public List<BaseVo> search(JSONObject option) {
        return Collections.emptyList();
    }
}
